﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OrderList0.aspx.cs" Inherits="WeChat.MenuReservation.OrderList0" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
    <title></title>
<script src="../Script/rem.js"></script> 
    <script src="../Script/jquery.min.js" type="text/javascript"></script>
    <link rel="stylesheet" type="text/css" href="../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="../css/page.css"/>
    <link rel="stylesheet" type="text/css" href="../css/all.css"/>
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../css/loaders.min.css"/>
    <link rel="stylesheet" type="text/css" href="../css/loading.css"/>
    <link href="../Script/slick/slick.css" rel="stylesheet" />
     <link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/1.1.2/weui.min.css"/>
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>  
    <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css"/>
	
	<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
    $(window).load(function () {
	$(".loading").addClass("loader-chanage")
	$(".loading").fadeOut(300)
    })
    var openid = "";
    var typename = "";
    var ismenu = "";
    var returntime = "";
    var deductions = "";
    var type = "";
    var dayprice = "";
    $(function () {
	function getUrlParam(openid) {
	    var reg = new RegExp("(^|&)" + openid + "=([^&]*)(&|$)");
	    var r = window.location.search.substr(1).match(reg);
	    if (r != null) return unescape(r[2]); return null;
	}
	openid = getUrlParam('openid');

	type = getUrlParam('type');
	SelectState('all');
	$.ajax({
	    type: "post",
	    url: "../MenuReserveHandler.ashx",
	    dataType: "json",
	    async: false,
	    data: { funcName: 'getall' },
	    success: function (data) {
		for (var i = 0; i < data.length; i++) {

		    typename = data[i].typename;
		    ismenu = data[i].ismenu;
		    returntime = data[i].returntime;
		    deductions = data[i].deductions;
		    dayprice = data[i].dayprice;
		}
	    },
	    error: function () {
		alert("异常！");
	    }
	});
    });
    function shan(OrderId) {
	$.ajax({
	    type: "post",
	    url: "../MenuReserveHandler.ashx",
	    dataType: "json",
	    async: false,
	    data: { OrderId: OrderId, funcName: 'getpayType' },
	    success: function (data) {
		for (var i = 0; i < data.length; i++) {

		    var payType = data[i].payType;
		    if (payType == "微信支付") {
			alert("微信退款");
		    }
		    else {
			$.ajax({
			    type: "post",
			    url: "../MenuReserveHandler.ashx",
			    dataType: "json",
			    async: false,
			    data: { OrderId: OrderId, funcName: 'Refund' },
			    success: function (data) {
				for (var i = 0; i < data.length; i++) {
				    kssj = data[i].kssj;
				}
			    },
			    error: function () {
				alert("异常！");
			    }
			});
		    }
		}
	    },
	    error: function () {
		alert("异常！");
	    }
	});

    }
    function Refund(OrderId, reservationdate, menuName, TimeState) {
	debugger
	var kssj = "";
	$.ajax({
	    type: "post",
	    url: "../MenuReserveHandler.ashx",
	    dataType: "json",
	    async: false,
	    data: { sdmc: TimeState, funcName: 'getTimeState' },
	    success: function (data) {
		for (var i = 0; i < data.length; i++) {
		    kssj = data[i].kssj;
		}
	    },
	    error: function () {
		alert("异常！");
	    }
	});

	$.ajax({
	    type: "post",
	    url: "../MenuReserveHandler.ashx",
	    dataType: "json",
	    async: false,
	    data: { funcName: 'getall' },
	    success: function (data) {
		for (var i = 0; i < data.length; i++) {
		    var returntime = data[i].returntime;
		    var d = new Date();
		    var a = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate() + " " + (d.getHours() + returntime) + ":" + d.getMinutes() + ":" + d.getSeconds();
		    var cc = reservationdate + " " + kssj;
		    if (new Date(a) < new Date(reservationdate + " " + kssj)) {
			$("#qu").remove();
			$(".weui-dialog__bd").html("退餐");
			$(".weui-dialog__ft").prepend('<a href="" class="weui-dialog__btn weui-dialog__btn_default" id="qu" style="text-decoration:none;">取消</a>');
			$("#qu").attr('href', "javascript:$('#dialog').hide();")
			$("#dialog").css("display", "block");
			$('#que').attr("onclick", "shan(" + OrderId + ")");
		    }
		    else {
			$(".weui-dialog__bd").html("已临近就餐时间，不可退餐!");
			$("#dialog").css("display", "block");
		    }
		}
	    },
	    error: function () {
		alert("异常！");
	    }
	});
    }
    function SelectState(state) {
	$("#Topayment,#Totakefood,#Havetakefood,#Toevaluate,#all").removeClass("cur");
	$("#" + state).addClass("cur");
	document.getElementById('accordion').innerText = "";

	$.ajax({
	    type: "post",
	    url: "../MenuReserveHandler.ashx",
	    data: { State: state, openid: openid, type: type, funcName: 'getOrderList' },
	    success: function (data) {
		$("#empty").remove();
		if (data == null || data == "[]") {
		    $("#accordion").after('<div style="text-align:center;padding-top:3rem;" id="empty"><img src="../images/order.png" style="width:2rem;" /><p style="padding-top:.3rem">没有相关订单</p></div>');
		}
		item = $.parseJSON(data);
		for (var i = 0; i < item.length; i++) {
		    var OrderId = item[i].OrderId;
		    var State = item[i].State;
		    if (type == "list1") {
			var menuName = item[i].cbname;
			var price = item[i].cbprice;
		    }
		    if (type == "list2") {

			var price = dayprice;
		    }
		    var OrderNum = item[i].OrderNum;
		    var str = item[i].reservationdate;
		    var TotalPrice = item[i].TotalPrice;
		    var tmp = /\d+(?=\+)/.exec(str);
		    var d = new Date(+tmp);
		    var reservationdate = d.getFullYear() + '-' + (+d.getMonth() + 1) + '-' + d.getDate();

		    var myar = new Array();
		    $($(".time")).each(function () {
			myar.push($(this).text());
		    });
		    if (myar.indexOf(OrderId) != -1) {
			if (State == "2") {
			    $("#" + OrderId + " .panel-body").prepend(' <div class="order-list clearfloat" id="list"><div class="list clearfloat fl box-s" name="list"><a href="#" style="text-decoration:none;color:black"><div class="middle clearfloat fl"><p class="tit">就餐时间：' + reservationdate + ' <a href="#" class="gopay-btn fr" style="text-decoration:none;" onclick="Refund(' + OrderId + ',\'' + reservationdate + '\',\'' + menuName + '\')">退餐</a ></p><p class="price clearfloat" style="color:black">' + menuName + '&nbsp;<span >￥' + price + '</span><span class="shu" style="margin-right:-20%;">×' + OrderNum + '</span></p></div></a></div></div>');

			} else {
			    $("#" + OrderId + " .panel-body").prepend(' <div class="order-list clearfloat" id="list"><div class="list clearfloat fl box-s" name="list"><a href="#" style="text-decoration:none;color:black"><div class="middle clearfloat fl"><p class="tit">就餐时间：' + reservationdate + ' </p><p class="price clearfloat" style="color:black">' + menuName + '&nbsp;<span >￥' + price + '</span><span class="shu" style="margin-right:-20%;">×' + OrderNum + '</span></p></div></a></div></div>');
			}
		    }
		    else {
			if (State == "1") {
			    $("#accordion").prepend(' <div class="panel panel-default"><div class="panel-heading"><a data-toggle="collapse" data-parent="#accordion" name="date" href="#' + OrderId + '"><h4 class="panel-title">订单号：<span class="time">' + OrderId + '</span><span class="orderstste" style="text-decoration:none;">待付款 </span></h4> </a></div><div id="' + OrderId + '" class="panel-collapse collapse"><div class="panel-body" style="padding:3%;"></div></div></div>');
			    if (type == "list1") {
				$("#" + OrderId + " .panel-body").prepend(' <div class="order-list clearfloat" id="list"><div class="list clearfloat fl box-s" name="list"><a href="#" style="text-decoration:none;color:black"><div class="middle clearfloat fl"><p class="tit">就餐时间：' + reservationdate + ' </p><p class="price clearfloat" style="color:black">' + menuName + '&nbsp;<span >￥' + price + '</span><span class="shu" style="margin-right:-20%;">×' + OrderNum + '</span></p></div></a></div><a href="../JsSDK/WxPay/SubmitOrder.aspx?price=' + TotalPrice + '&OrderID=' + OrderId + '&openid=' + openid + '" class="gopay-btn fr" style="text-decoration:none;">立即支付</a ></div>');
			    } else {
				$("#" + OrderId + " .panel-body").prepend(' <div class="order-list clearfloat" id="list"><div class="list clearfloat fl box-s" name="list"><a href="#" style="text-decoration:none;color:black"><div class="middle clearfloat fl"><p class="tit">就餐时间：' + reservationdate + ' </p><p class="price clearfloat" style="color:black"><span >￥' + price + '</span><span class="shu" style="margin-right:-20%;">×' + OrderNum + '</span></p></div></a></div><a href="../JsSDK/WxPay/SubmitOrder.aspx?price=' + TotalPrice + '&OrderID=' + OrderId + '&openid=' + openid + '" class="gopay-btn fr" style="text-decoration:none;">立即支付</a ></div>');
			    }
			}
			if (State == "2") {
			    $("#accordion").prepend(' <div class="panel panel-default"><div class="panel-heading"><a data-toggle="collapse" data-parent="#accordion" name="date" href="#' + OrderId + '"><h4 class="panel-title">订单号：<span class="time">' + OrderId + '</span><span class="orderstste" style="text-decoration:none;">待取餐 </span></h4></a></div><div id="' + OrderId + '" class="panel-collapse collapse"><div class="panel-body" style="padding:3%;"></div></div></div>');
			    if (type == "list1") {
				$("#" + OrderId + " .panel-body").prepend(' <div class="order-list clearfloat" id="list"><div class="list clearfloat fl box-s" name="list"><a href="#" style="text-decoration:none;color:black"><div class="middle clearfloat fl"><p class="tit">就餐时间：' + reservationdate + ' <a href="#" class="gopay-btn fr" style="text-decoration:none;" onclick="Refund(' + OrderId + ',\'' + reservationdate + '\',\'' + menuName + '\')">退餐</a ></p><p class="price clearfloat" style="color:black">' + menuName + '&nbsp;<span >￥' + price + '</span><span class="shu" style="margin-right:-20%;">×' + OrderNum + '</span></p></div></a></div></div>');
			    } else {
				$("#" + OrderId + " .panel-body").prepend(' <div class="order-list clearfloat" id="list"><div class="list clearfloat fl box-s" name="list"><a href="#" style="text-decoration:none;color:black"><div class="middle clearfloat fl"><p class="tit">就餐时间：' + reservationdate + ' <a href="#" class="gopay-btn fr" style="text-decoration:none;" onclick="Refund(' + OrderId + ',\'' + reservationdate + '\',\'' + menuName + '\')">退餐</a ></p><p class="price clearfloat" style="color:black"><span >￥' + price + '</span><span class="shu" style="margin-right:-20%;">×' + OrderNum + '</span></p></div></a></div></div>');
			    }
			}
			if (State == "3") {
			    $("#accordion").prepend(' <div class="panel panel-default"><div class="panel-heading"><a data-toggle="collapse" data-parent="#accordion" name="date" href="#' + OrderId + '"><h4 class="panel-title">订单号：<span class="time">' + OrderId + '</span><span class="orderstste" style="text-decoration:none;">已取餐 </span></h4></a></div><div id="' + OrderId + '" class="panel-collapse collapse"><div class="panel-body" style="padding:3%;"></div></div></div>');
			    if (type == "list1") {
				$("#" + OrderId + " .panel-body").prepend(' <div class="order-list clearfloat" id="list"><div class="list clearfloat fl box-s" name="list"><a href="#" style="text-decoration:none;color:black"><div class="middle clearfloat fl"><p class="tit">就餐时间：' + reservationdate + ' </p><p class="price clearfloat" style="color:black">' + menuName + '&nbsp;<span >￥' + price + '</span><span class="shu" style="margin-right:-20%;">×' + OrderNum + '</span></p></div></a></div></div>');
			    } else {
				$("#" + OrderId + " .panel-body").prepend(' <div class="order-list clearfloat" id="list"><div class="list clearfloat fl box-s" name="list"><a href="#" style="text-decoration:none;color:black"><div class="middle clearfloat fl"><p class="tit">就餐时间：' + reservationdate + ' </p><p class="price clearfloat" style="color:black"><span >￥' + price + '</span><span class="shu" style="margin-right:-20%;">×' + OrderNum + '</span></p></div></a></div></div>');

			    }
			}
		    }

		}

	    },
	    error: function () {
		alert("异常！");
	    }
	});
    }

</script>
</head>
<!--loading页开始-->
<div class="loading">
	<div class="loader">
        <div class="loader-inner pacman">
          <div></div>
          <div></div>
          <div></div>
          <div></div>
          <div></div>
        </div>
	</div>
</div>
<!--loading页结束-->
<body>
		<header class="mui-bar mui-bar-nav report-header box-s" id="header" >
			<a href="javascript:history.go(-1)"><i class="iconfont icon-fanhui fl"></i></a>
			<p>全部订单</p>
	    </header>
	    <div id="main" class="sjfenlei mui-clearfix">
            
	    	<div class="order-top clearfloat" style="position:fixed;z-index: 10;">
	    		<ul>
	    			<li class="clearfloat" onclick="SelectState('all')" id="all" style="width:25%"><a href="#" style="text-decoration:none">全部</a></li>
	    			<li class="clearfloat" onclick="SelectState('Topayment')" id="Topayment"  style="width:25%"><a href="#" style="text-decoration:none">待付款</a></li>
	    			<li class="clearfloat" onclick="SelectState('Totakefood')" id="Totakefood"  style="width:25%"><a href="#" style="text-decoration:none">待取餐</a></li>
	    			<li class="clearfloat" onclick="SelectState('Havetakefood')" id="Havetakefood"  style="width:25%"><a href="#" style="text-decoration:none">已取餐</a></li>
	    		<%--	<li class="clearfloat" onclick="SelectState('Toevaluate')" id="Toevaluate"><a href="#">待评价</a></li>--%>
	    		</ul>
	    	</div>
         
       <%--     <div class="order-list clearfloat" style="padding-top:1rem" id="list">
	    		<p class="ordernum box-s" >
	    			订单号  123456789000
	    			<span>待付款</span>
	    		</p>
	    		<div class="list clearfloat fl box-s"> 
	    			<a href="#">
		    			<div class="tu fl clearfloat">
		    				<img src="upload/21.jpg"/>
		    			</div>
		    			<div class="middle clearfloat fl">
		    				<p class="tit">野山茶油</p>
		    			
		    				<p class="price clearfloat">
		    					<span class="xprice fl">￥299.00</span>
		    					
		    					<span class="shu">×1</span>
		    				</p>
		    			</div>
	    			</a>
	    		</div>
	    		<div class="list clearfloat fl box-s">
	    			<a href="detail.html">
		    			<div class="tu fl clearfloat">
		    				<img src="upload/21.jpg"/>
		    			</div>
		    			<div class="middle clearfloat fl">
		    				<p class="tit">野山茶油</p>
		    				<p class="fu-tit"></p>
		    				<p class="price clearfloat">
		    					<span class="xprice fl">￥299.00</span>
		    				
		    					<span class="shu">×1</span>
		    				</p>
		    			</div>
	    			</a>
	    		</div>
	    	
	    	</div>--%>
	

            <div class="panel-group" id="accordion"style="padding-top:2rem">

	<%--<div class="panel panel-default">
		<div class="panel-heading">
           <a data-toggle="collapse" data-parent="#accordion" 
				   href="#collapseOne">
			<h4 class="panel-title">  
                 
					点击我进行展开，再次点击我进行折叠。第 1 部分<span class="orderstste">未付款 </span>
				
			</h4>
                </a>
		</div>
		<div id="collapseOne" class="panel-collapse collapse in">
			<div class="panel-body" style="padding:3%;">
                <div class="order-list clearfloat" id="list">
				 <div class="list clearfloat fl box-s" name="list">
         <a href="#">
             <div class="tu fl clearfloat"><img src="upload/21.jpg"/></div>
             <div class="middle clearfloat fl">
                 <p class="tit">菜</p>
                 <p class="price clearfloat">
                     <span class="xprice fl">￥12</span>
                     <span class="shu">×1</span>
                 </p></div></a></div>
			</div>
                 <div class="order-list clearfloat" id="list">
				 <div class="list clearfloat fl box-s" name="list">
         <a href="#">
             <div class="tu fl clearfloat"><img src="upload/21.jpg"/></div>
             <div class="middle clearfloat fl">
                 <p class="tit">菜</p>
                 <p class="price clearfloat">
                     <span class="xprice fl">￥12</span>
                     <span class="shu">×1</span>
                 </p></div></a></div>
			</div>
                </div>
		</div>
	</div>
	<div class="panel panel-default">
		<div class="panel-heading">
			<h4 class="panel-title">
				<a data-toggle="collapse" data-parent="#accordion" 
				   href="#collapseTwo">
					点击我进行展开，再次点击我进行折叠。第 2 部分 
				</a>
               <span class="orderstste" style="text-decoration:none">未付款 </span>
			</h4>
		</div>
		<div id="collapseTwo" class="panel-collapse collapse">
			<div class="panel-body">
				Nihil anim keffiyeh helvetica, craft beer labore wes anderson 
				cred nesciunt sapiente ea proident. Ad vegan excepteur butcher 
				vice lomo.
			</div>
		</div>
	</div>
	<div class="panel panel-default">
		<div class="panel-heading">
			<h4 class="panel-title">
				<a data-toggle="collapse" data-parent="#accordion" 
				   href="#collapseThree">
					点击我进行展开，再次点击我进行折叠。第 3 部分<span class="orderstste">未付款 </span>
				</a>
			</h4>
		</div>
		<div id="collapseThree" class="panel-collapse collapse">
			<div class="panel-body">
				123
			</div>
		</div>
	</div>
<div class="panel panel-default">
		<div class="panel-heading">
			<h4 class="panel-title">
				<a data-toggle="collapse" data-parent="#accordion" 
				   href="#collapse1">
					点击我进行展开，再次点击我进行折叠。第 3 部分<span class="orderstste">未付款 </span>
				</a>
			</h4>
		</div>
		<div id="collapse1" class="panel-collapse collapse">
			<div class="panel-body">
				123456
			</div>
		</div>
	</div>--%>
</div>
 <%--           <div id="accordion" style="padding-top:3rem" >
  <h3>部分 1</h3>
  <div>
    <p>
    Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer
   
    </p>
  </div>
  <h3>部分 2</h3>
  <div>
    <p>
    Sed non 
    </p>
  </div>
  <h3>部分 3</h3>
  <div>
    <p>
  
    lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
    </p>
   
  </div>
  <h3>部分 4</h3>
  <div>
    <p>
  et ultrices posuere cubilia Curae; Aenean lacinia
    mauris vel est.
    </p>
    <p>
   citi sociosqu ad litora torquent per conubia nostra, per
    inceptos himenaeos.
    </p>
  </div>
</div>--%>
  <div style="display: none;"   id="dialog">
    <div class="weui-mask"></div>
    <div class="weui-dialog">
        <div class="weui-dialog__hd"><strong class="weui-dialog__title">提示</strong></div>
        <div class="weui-dialog__bd"></div>
        <div class="weui-dialog__ft">
            <a  href="javascript:$('#dialog').hide();" class="weui-dialog__btn weui-dialog__btn_primary" id="que" style="text-decoration:none;">确定</a>
        </div>
    </div>
</div>
	    	<style type="text/css">
	    		.more-btn{width: 25%; padding: 3% 0; text-align: center; background-color: #00CC7D; color: #fff; font-size: .5rem; margin: 5% auto;}
	    	    .orderstste {
                     font-size: .35rem;
            margin-left: 3%;
            padding: .1rem;
            background-color: #25cb83;
            color: #fff;
	    	    }
                </style>
	    	<%--<a href="#" class="more-btn db ra5">更多</a>--%>
	    </div>
    <!--footer star-->
	    <footer class="page-footer fixed-footer" id="footer">
			<ul>
				<%--<li>
					<a href="index.html">
						<i class="iconfont icon-shouye"></i>
						<p>首页</p>
					</a>
				</li>--%>

				<li class="right">
					<a href="ReserveMenu.aspx" style="text-decoration:none;">
						<i class="iconfont icon-icon04"></i>
						<p>在线订餐</p>
					</a>
				</li>
				<li class="active">
					<a href="#" style="text-decoration:none;">
						<i class="iconfont icon-gouwuche"></i>
						<p>我的订餐</p>
					</a>
				</li>
				<%--<li>
					<a href="login.html">
						<i class="iconfont icon-yonghuming"></i>
						<p>个人中心</p>
					</a>
				</li>--%>
			</ul>
		</footer>
		<!--footer end-->
	</body>
	<script type="text/javascript" src="../Script/jquery-1.8.3.min.js" ></script>
	<script src="../Script/fastclick.js"></script>
	<script src="../Script/mui.min.js"></script>
	<script type="text/javascript" src="../Script/hmt.js" ></script>
  <%--  <script src="../Script/mui.min.js"></script>--%>
<%--<script src="../Script/others.js"></script>
<script type="text/javascript" src="../Script/hmt.js"></script>--%>
<%--<script src="../Script/slick/slick.js" type="text/javascript"></script>
<script src="../Script/shopcar.js"></script>--%>
</html>
